﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;

/// <summary>
/// Dummy widget for testing purposes
/// </summary>
public partial class WidgetDummy : WidgetBase
{
    /// <summary>
    /// Gets the name of the widget. It must be exactly the same as the folder that contains the widget.
    /// </summary>
    /// <value></value>
    public override string Name
    {
        get { return "DummyWidget"; }
    }

    /// <summary>
    /// Gets the title. Title is shown in the header of the widget container.
    /// </summary>
    /// <value>The title.</value>
    public override string Title
    {
        get { return "Dummy Widget"; }
    }
    /// <summary>
    /// This method works as a substitute for Page_Load. You should use this method for
    /// data binding etc. instead of Page_Load.
    /// </summary>
    public override void LoadWidget()
    {
        LiteralTime.Text = DateTime.Now.ToString();
        StringDictionary settings = GetSettings();
        
        if (settings["country"] != null)
        {
            TextBoxCountry.Text = settings["country"];
        }
    }

    /// <summary>
    /// Shows the edit.
    /// </summary>
    public override void ShowEdit()
    {
        DivEdit.Visible = true;
    }


    /// <summary>
    /// Saves the settings.
    /// </summary>
    public void Save()
    {
        StringDictionary settings = GetSettings();
        settings["country"] = TextBoxCountry.Text;
        SaveSettings(settings);
    }

    /// <summary>
    /// Hides the edit.
    /// </summary>
    public override void HideEdit()
    {
        Save();
        DivEdit.Visible = false;
    }

    /// <summary>
    /// Gets a value indicating whether this instance is editable.
    /// </summary>
    /// <value>
    /// 	<c>true</c> if this instance is editable; otherwise, <c>false</c>.
    /// </value>
    public override bool IsEditable
    {
        get { return true; }
    }
}
